package anshe.struct
{
	import anshe.widget.AnsheClient;
	
	public class ActionStruct extends Object
	{
		public var id:Number;				//	消息的 ID 号（该值不允许修改）
		public var actClient:Object;		//	发送命令的客户端		
		public var actFunction:String;		//	需要回调的函数	
		public var actString:String;		//	（仅针对发送方）命令行语句
		public var actData:Array;			//	（仅针对发送方）要发送的数据
		public var isSoMessage:Boolean;		//	是否为 SharedObject 直接处理消息
		public var isGlobal:Boolean;		//	是否为全局消息（标识决定消息处理方是否为游戏或用户管理器）
		
		public function ActionStruct(actID:Number)
		{
			id = actID;
			isSoMessage = false;
			isGlobal = false;
			actClient = null;
			actString = "";
			actFunction = "";			
		}
		
		public function DoFunction(argc:Array):void
		{
			// trace("input argc:: " + argc);
			// trace("this.actclient::" + this.actClient);
			
			if(actClient)
			{
				//try
				//{
					if(actClient[actFunction] is Function)
					{
						// trace("can do " + actFunction);
						
						var fn:Function = actClient[actFunction];
						fn.call(null, argc);
					}
				//}
				//catch(e:*)
				//{
					//trace("Do Function " + actFunction + " can't action");
				//}
			}
		}
		
		public function toString():String
		{
			return 	" id : " + this.id +
					" client : " + this.actClient +
					" keyword : " + this.actString + 
					" function : " + this.actFunction +
					" isGlobal : " + this.isGlobal +
					" data : " + this.actData;
		}
	}
}